<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/7/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/7/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/10/29/IIC%E8%AF%BB%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%AE%8C%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%AD%97%E8%8A%82%E5%B9%B6%E5%BA%94%E7%AD%94%E5%90%8E%E8%AF%BB%E4%B8%8D%E5%87%BA%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%AD%97%E8%8A%82/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/10/29/IIC%E8%AF%BB%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%AE%8C%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%AD%97%E8%8A%82%E5%B9%B6%E5%BA%94%E7%AD%94%E5%90%8E%E8%AF%BB%E4%B8%8D%E5%87%BA%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%AD%97%E8%8A%82/" class="post-title-link" itemprop="url">IIC读数据读完第一个字节并应答后读不出第二个字节</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-10-29 16:05:22" itemprop="dateCreated datePublished" datetime="2023-10-29T16:05:22+08:00">2023-10-29</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/10/29/IIC%E8%AF%BB%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%AE%8C%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%AD%97%E8%8A%82%E5%B9%B6%E5%BA%94%E7%AD%94%E5%90%8E%E8%AF%BB%E4%B8%8D%E5%87%BA%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%AD%97%E8%8A%82/" class="post-meta-item leancloud_visitors" data-flag-title="IIC读数据读完第一个字节并应答后读不出第二个字节" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/10/29/IIC%E8%AF%BB%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%AE%8C%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%AD%97%E8%8A%82%E5%B9%B6%E5%BA%94%E7%AD%94%E5%90%8E%E8%AF%BB%E4%B8%8D%E5%87%BA%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%AD%97%E8%8A%82/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/10/29/IIC%E8%AF%BB%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%AE%8C%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%AD%97%E8%8A%82%E5%B9%B6%E5%BA%94%E7%AD%94%E5%90%8E%E8%AF%BB%E4%B8%8D%E5%87%BA%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%AD%97%E8%8A%82/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_47246667/article/details/127802285">https://blog.csdn.net/weixin_47246667/article/details/127802285</a></p>
<p>​    在使用IIC读取传感器数据时，给从机读取命令并收到从机应答，接收到第一个字节后给从机应答信号，但此时接收不到第二个字节的数据。这种情况可能是应答信号的问题。原本应答函数为：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">IIC_Ack</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	IIC_SCL=<span class="number">0</span>;</span><br><span class="line">	SDA_OUT();</span><br><span class="line">	IIC_SDA=<span class="number">0</span>;</span><br><span class="line">	delay_us(<span class="number">2</span>);</span><br><span class="line">	IIC_SCL=<span class="number">1</span>;</span><br><span class="line">	delay_us(<span class="number">2</span>);</span><br><span class="line">	IIC_SCL=<span class="number">0</span>;</span><br><span class="line"> </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在主机应答后，要将SDA拉高，以便下一次传输，改成这样：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">IIC_Ack</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	IIC_SCL=<span class="number">0</span>;</span><br><span class="line">	SDA_OUT();</span><br><span class="line">	IIC_SDA=<span class="number">0</span>;</span><br><span class="line">	delay_us(<span class="number">2</span>);</span><br><span class="line">	IIC_SCL=<span class="number">1</span>;</span><br><span class="line">	delay_us(<span class="number">2</span>);</span><br><span class="line">	IIC_SCL=<span class="number">0</span>;</span><br><span class="line">	delay_us(<span class="number">2</span>);</span><br><span class="line">	IIC_SDA=<span class="number">1</span>;</span><br><span class="line">	delay_us(<span class="number">2</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>修改应答信号后即可解决问题。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/10/29/%E4%BD%BF%E7%94%A8%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%BB%AA%E7%9C%8BIIC%E5%8D%8F%E8%AE%AE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/10/29/%E4%BD%BF%E7%94%A8%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%BB%AA%E7%9C%8BIIC%E5%8D%8F%E8%AE%AE/" class="post-title-link" itemprop="url">使用逻辑分析仪看IIC协议</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-10-29 13:59:51" itemprop="dateCreated datePublished" datetime="2023-10-29T13:59:51+08:00">2023-10-29</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B7%A5%E5%85%B7/" itemprop="url" rel="index"><span itemprop="name">工具</span></a>
                </span>
            </span>

          
            <span id="/2023/10/29/%E4%BD%BF%E7%94%A8%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%BB%AA%E7%9C%8BIIC%E5%8D%8F%E8%AE%AE/" class="post-meta-item leancloud_visitors" data-flag-title="使用逻辑分析仪看IIC协议" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/10/29/%E4%BD%BF%E7%94%A8%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%BB%AA%E7%9C%8BIIC%E5%8D%8F%E8%AE%AE/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/10/29/%E4%BD%BF%E7%94%A8%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%BB%AA%E7%9C%8BIIC%E5%8D%8F%E8%AE%AE/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="写"><a href="#写" class="headerlink" title="写"></a>写</h3><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20231029140110.png"></p>
<p>​        绿点是IIC的起始信号，红框是IIC的结束信号，上图是往0x40的设备地址的0x40寄存器写入0x4207数据，往0x41寄存器写入0x0004数据。</p>
<p>​        所有的SDA 信号<strong>变化都要在SCL 时钟为低电平时进行</strong>，除了开始和结束标志，IIC的起始和停止条件：</p>
<ul>
<li>起始：时钟线SCL为高时，数据线SDA由高到低</li>
<li>停止：时钟线SCL为高时，数据线SDA由低到高</li>
</ul>
<p>​        另外然后应答产生时，从设备将SDA 线拉低并且在SCL 为高电平时保持低，如下图所示：</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20231029141418.png"></p>
<h3 id="读"><a href="#读" class="headerlink" title="读"></a>读</h3><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20231029142512.png"></p>
<p>上图是从0x40地址的设备，读取0x01寄存器里面的值为0x8222。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20231029142911.png"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/10/16/%E9%9B%B7%E8%BE%BE%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E6%97%B6%E7%A9%BA%E9%A2%91%E9%87%87%E6%A0%B7/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/10/16/%E9%9B%B7%E8%BE%BE%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E6%97%B6%E7%A9%BA%E9%A2%91%E9%87%87%E6%A0%B7/" class="post-title-link" itemprop="url">雷达信号处理中的时空频采样</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-10-16 16:54:31" itemprop="dateCreated datePublished" datetime="2023-10-16T16:54:31+08:00">2023-10-16</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E9%9B%B7%E8%BE%BE/" itemprop="url" rel="index"><span itemprop="name">雷达</span></a>
                </span>
            </span>

          
            <span id="/2023/10/16/%E9%9B%B7%E8%BE%BE%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E6%97%B6%E7%A9%BA%E9%A2%91%E9%87%87%E6%A0%B7/" class="post-meta-item leancloud_visitors" data-flag-title="雷达信号处理中的时空频采样" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/10/16/%E9%9B%B7%E8%BE%BE%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E6%97%B6%E7%A9%BA%E9%A2%91%E9%87%87%E6%A0%B7/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/10/16/%E9%9B%B7%E8%BE%BE%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E6%97%B6%E7%A9%BA%E9%A2%91%E9%87%87%E6%A0%B7/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          Here's something encrypted, password is required to continue reading.
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/10/16/%E9%9B%B7%E8%BE%BE%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86%E4%B8%AD%E7%9A%84%E6%97%B6%E7%A9%BA%E9%A2%91%E9%87%87%E6%A0%B7/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/10/15/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AEPWM/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/10/15/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AEPWM/" class="post-title-link" itemprop="url">STM32使用cubemx配置PWM</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-10-15 14:11:34" itemprop="dateCreated datePublished" datetime="2023-10-15T14:11:34+08:00">2023-10-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/10/15/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AEPWM/" class="post-meta-item leancloud_visitors" data-flag-title="STM32使用cubemx配置PWM" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/10/15/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AEPWM/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/10/15/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AEPWM/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="CubeMX操作步骤"><a href="#CubeMX操作步骤" class="headerlink" title="CubeMX操作步骤"></a>CubeMX操作步骤</h3><p>​    配置界面找到Timers配置栏，配置TIM3时钟为内部时钟（internal clock），同时选择通道1和2为PWM模式（PWM Generation CH1，PWM Generation CH2）</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310151422521.png" style="zoom:70%;">

<p>​        配置TIM3的具体参数，主要为分频值和重装载值，修改分频值为8399，重装载值为4999，使一个PWM的周期为：（4999+1）x（8399+1）/84000000 = 0.5s</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310151438141.png" style="zoom:80%;">

<h3 id="选取代码"><a href="#选取代码" class="headerlink" title="选取代码"></a>选取代码</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">TIM_HandleTypeDef htim3;</span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">MX_TIM3_Init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM3_Init 0 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM3_Init 0 */</span></span><br><span class="line">  TIM_ClockConfigTypeDef sClockSourceConfig = &#123;<span class="number">0</span>&#125;;</span><br><span class="line">  TIM_MasterConfigTypeDef sMasterConfig = &#123;<span class="number">0</span>&#125;;</span><br><span class="line">  TIM_OC_InitTypeDef sConfigOC = &#123;<span class="number">0</span>&#125;;</span><br><span class="line"></span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM3_Init 1 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM3_Init 1 */</span></span><br><span class="line">  htim3.Instance = TIM3;</span><br><span class="line">  htim3.Init.Prescaler = <span class="number">8399</span>;</span><br><span class="line">  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;</span><br><span class="line">  htim3.Init.Period = <span class="number">4999</span>;</span><br><span class="line">  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;</span><br><span class="line">  htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIM_Base_Init(&amp;htim3) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIM_ConfigClockSource(&amp;htim3, &amp;sClockSourceConfig) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIM_PWM_Init(&amp;htim3) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;</span><br><span class="line">  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIMEx_MasterConfigSynchronization(&amp;htim3, &amp;sMasterConfig) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  sConfigOC.OCMode = TIM_OCMODE_PWM1;</span><br><span class="line">  sConfigOC.Pulse = <span class="number">2499</span>;</span><br><span class="line">  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;</span><br><span class="line">  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIM_PWM_ConfigChannel(&amp;htim3, &amp;sConfigOC, TIM_CHANNEL_1) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIM_PWM_ConfigChannel(&amp;htim3, &amp;sConfigOC, TIM_CHANNEL_2) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM3_Init 2 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM3_Init 2 */</span></span><br><span class="line">  HAL_TIM_MspPostInit(&amp;htim3);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//这个函数会被HAL_TIM_Base_Init函数调用</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">HAL_TIM_Base_MspInit</span><span class="params">(TIM_HandleTypeDef* htim_base)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">if</span>(htim_base-&gt;Instance==TIM3)</span><br><span class="line">  &#123;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM3_MspInit 0 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM3_MspInit 0 */</span></span><br><span class="line">    <span class="comment">/* Peripheral clock enable */</span></span><br><span class="line">    __HAL_RCC_TIM3_CLK_ENABLE();</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM3_MspInit 1 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM3_MspInit 1 */</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">HAL_TIM_MspPostInit</span><span class="params">(TIM_HandleTypeDef* htim)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  GPIO_InitTypeDef GPIO_InitStruct = &#123;<span class="number">0</span>&#125;;</span><br><span class="line">  <span class="keyword">if</span>(htim-&gt;Instance==TIM3)</span><br><span class="line">  &#123;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM3_MspPostInit 0 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM3_MspPostInit 0 */</span></span><br><span class="line">    __HAL_RCC_GPIOC_CLK_ENABLE();</span><br><span class="line">    <span class="comment">/**TIM3 GPIO Configuration</span></span><br><span class="line"><span class="comment">    PC6     ------&gt; TIM3_CH1</span></span><br><span class="line"><span class="comment">    PC7     ------&gt; TIM3_CH2</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;</span><br><span class="line">    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;</span><br><span class="line">    GPIO_InitStruct.Pull = GPIO_NOPULL;</span><br><span class="line">    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;</span><br><span class="line">    GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;</span><br><span class="line">    HAL_GPIO_Init(GPIOC, &amp;GPIO_InitStruct);</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM3_MspPostInit 1 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM3_MspPostInit 1 */</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在完成以上设置了之后，我们就需要开启PWM信号产生器：</p>
<p>HAL_TIM_PWM_Start(&amp;htim3,TIM_CHANNEL_1); </p>
<p>HAL_TIM_PWM_Start(&amp;htim3,TIM_CHANNEL_2); </p>
<p>这样就ok了。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/10/15/%E7%AB%8B%E5%88%9BEDA%E5%8E%9F%E7%90%86%E5%9B%BE%E5%8F%8APCB%E7%BB%98%E5%88%B6%E6%B5%81%E7%A8%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/10/15/%E7%AB%8B%E5%88%9BEDA%E5%8E%9F%E7%90%86%E5%9B%BE%E5%8F%8APCB%E7%BB%98%E5%88%B6%E6%B5%81%E7%A8%8B/" class="post-title-link" itemprop="url">立创EDA原理图及PCB绘制流程</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-10-15 14:11:34" itemprop="dateCreated datePublished" datetime="2023-10-15T14:11:34+08:00">2023-10-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2023/10/15/%E7%AB%8B%E5%88%9BEDA%E5%8E%9F%E7%90%86%E5%9B%BE%E5%8F%8APCB%E7%BB%98%E5%88%B6%E6%B5%81%E7%A8%8B/" class="post-meta-item leancloud_visitors" data-flag-title="立创EDA原理图及PCB绘制流程" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/10/15/%E7%AB%8B%E5%88%9BEDA%E5%8E%9F%E7%90%86%E5%9B%BE%E5%8F%8APCB%E7%BB%98%E5%88%B6%E6%B5%81%E7%A8%8B/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/10/15/%E7%AB%8B%E5%88%9BEDA%E5%8E%9F%E7%90%86%E5%9B%BE%E5%8F%8APCB%E7%BB%98%E5%88%B6%E6%B5%81%E7%A8%8B/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>   参考原文：<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_47134270/article/details/128424919">https://blog.csdn.net/qq_47134270/article/details/128424919</a></p>
<h3 id="原理图绘制"><a href="#原理图绘制" class="headerlink" title="原理图绘制"></a>原理图绘制</h3><p><strong>非连接标志</strong></p>
<p>​    非连接标志用于原理图上元器件不使用或需要悬空的引脚，避免出现引脚没有进行网络连接而在设计管理器内报错。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310152120809.png" style="zoom:80%;">

<p>这个要直接放置在元器件的引脚上。</p>
<p><strong>网络标签</strong></p>
<p>​        假如某两个需要连接的管脚距离比较远，不适合用导线连接。可以用标签，如下（网络标签的名字随便写，连接的两者要保证一样）</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310152127195.png" style="zoom:67%;">

<p>​        原理图绘制完之后，点击“设计”，“检查DRC”:</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310292151381.png" style="zoom:70%;">

<p>​        然后再点击“设计”，“更新/转换原理图到PCB”, 就生成了相应的pcb文件。</p>
<h3 id="PCB绘制"><a href="#PCB绘制" class="headerlink" title="PCB绘制"></a>PCB绘制</h3><h4 id="（1）放置板框"><a href="#（1）放置板框" class="headerlink" title="（1）放置板框"></a>（1）放置板框</h4><p>在图层选项卡中选择“其他”，“板框层”，被选中的这个层前面就多了一个笔的记号：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310292217127.png" style="zoom:67%;">

<p>选择“放置”，“板框”，“矩形”来设置板框：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310302100180.png" style="zoom:60%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310302109641.png" style="zoom:67%;">

<h4 id="（2）绘制定位孔"><a href="#（2）绘制定位孔" class="headerlink" title="（2）绘制定位孔"></a>（2）绘制定位孔</h4><p>​        定位孔作用：PCB电路板在组装成品时要做螺丝固定孔使用。定位孔可以使用矩形、圆形或者多边形。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310302227407.png" style="zoom:67%;">

<p>定位孔是在多层这一层(待板子出来后确认一下)。</p>
<h4 id="（3）布局"><a href="#（3）布局" class="headerlink" title="（3）布局"></a>（3）布局</h4><p>​        确定好定位孔后，再来确定元件的布局 ，元件布局一般遵循以下规则：</p>
<p>1、为了方便自动焊接，每一边都要留出 3.5 mm 的传送边。要是不够的话，就可以考虑加工艺传送边。</p>
<p>2、一般的情况下，元器件常常会布置在pcb板的顶层上。如果顶层元件过于密集，我们可以考虑把部分高度有限、而且发热量较小的器件放到底层（如贴片电阻、电容等）</p>
<p>3、一般将模块放到同一片区域进行布局，减少后面布线的复杂性，譬如：选中晶振电路，使用设计中的布局传递，它会自动在PCB中选中模块的所有零件，我们再对它进行布局即可。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310302233993.png" style="zoom:50%;">

<p>在图层选项卡中选择<strong>顶层</strong>，然后开始放置元器件，中途也可以把器件修改到<strong>底层</strong>。</p>
<h4 id="4-布线"><a href="#4-布线" class="headerlink" title="(4) 布线"></a>(4) 布线</h4><p>​        立创EDA支持自动布线，点击布线中的自动布线即可。 当然，也可以自行布线，在顶部菜单栏点击如下图标。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310302312938.png"></p>
<p>​        当你选中一条导线时，可以在右边属性面板修改它对应的属性。</p>
<p>​        在布线过程中使用 快捷键 “+”，“ - ” 可以很方便地调节当前的走线的大小。按 TAB键 修改线宽参数。</p>
<p>​        布线时，如果你想布一段线段后，下一段线增大线宽，可以按 “SHIFT+W” 快速切换导线宽度。</p>
<p>​        当你绘制一个双层板或多层板时你可以放置过孔，使顶层和底层导通。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310310837362.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310310838157.png" style="zoom:70%;">

<h4 id="（5）添加丝印"><a href="#（5）添加丝印" class="headerlink" title="（5）添加丝印"></a>（5）添加丝印</h4><p>​        先切换到顶层丝印层，使用顶部菜单栏的文本即可添加丝印</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310312155286.png"></p>
<h4 id="（6）添加泪滴"><a href="#（6）添加泪滴" class="headerlink" title="（6）添加泪滴"></a>（6）添加泪滴</h4><p>​        泪滴的作用是放置导线断裂，起到保护作用。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310312207724.png" style="zoom:50%;">

<h4 id="（7）铺铜"><a href="#（7）铺铜" class="headerlink" title="（7）铺铜"></a>（7）铺铜</h4><p>​        铺铜可以减小地线阻抗，提高抗干扰能力；降低压降，提高电源效率；与地线相连，还可以减小环路面积。在<strong>顶层和底层分别点击</strong>顶部菜单栏的铺铜符号，选中整块PCB，出现以下弹窗。网络一般选择GND，铺地铜，其他参数默认即可。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310312213658.png"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310312214410.png" style="zoom:67%;">

<h4 id="（8）DRC检查"><a href="#（8）DRC检查" class="headerlink" title="（8）DRC检查"></a>（8）DRC检查</h4><p>​        和原理图一样，PCB也需要进行DRC检查，检查未出现错误后说明板子已经画好啦！</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310312216293.png" style="zoom:67%;">

<h4 id="9-显示3D效果"><a href="#9-显示3D效果" class="headerlink" title="(9) 显示3D效果"></a>(9) 显示3D效果</h4><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310312220099.png"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310312227122.png" style="zoom:50%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/10/13/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AE%E9%80%9A%E7%94%A8%E5%AE%9A%E6%97%B6%E5%99%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/10/13/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AE%E9%80%9A%E7%94%A8%E5%AE%9A%E6%97%B6%E5%99%A8/" class="post-title-link" itemprop="url">STM32使用cubemx配置通用定时器</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-10-13 21:32:08" itemprop="dateCreated datePublished" datetime="2023-10-13T21:32:08+08:00">2023-10-13</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/10/13/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AE%E9%80%9A%E7%94%A8%E5%AE%9A%E6%97%B6%E5%99%A8/" class="post-meta-item leancloud_visitors" data-flag-title="STM32使用cubemx配置通用定时器" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/10/13/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AE%E9%80%9A%E7%94%A8%E5%AE%9A%E6%97%B6%E5%99%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/10/13/STM32%E4%BD%BF%E7%94%A8cubemx%E9%85%8D%E7%BD%AE%E9%80%9A%E7%94%A8%E5%AE%9A%E6%97%B6%E5%99%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="CubeMX操作步骤"><a href="#CubeMX操作步骤" class="headerlink" title="CubeMX操作步骤"></a>CubeMX操作步骤</h3><p>​    配置定时器2，这里我们使用定时器2来实现定时的功能。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310132159712.png" style="zoom:70%;">

<p>TIM2定时器的时钟源来源于APB1，因此在这里我们可以记下来设置的APB1定时器的时钟为下图的84MHz。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310132239862.png" style="zoom:67%;">

<p>​        结合时钟页面中的Parameter Settings，在这里我们可以在下方看到Prescaler(PSC)和Counter Period(ARR)，这两者共同决定了定时器的频率，公式如下：Tout= ((arr+1)*(psc+1))/Tclk；按图中设置的参数，那么定时时间是：（4999+1）x（8399+1）/84000000 = 0.5s</p>
<p>​    配置中断。如下图所示，开启定时器2的中断。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310132204431.png" style="zoom:67%;">

<p>​    如下图所示，生成定时器2中断优先级配置代码。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310132221994.png" style="zoom:67%;">

<h3 id="选取代码"><a href="#选取代码" class="headerlink" title="选取代码"></a>选取代码</h3><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//初始化有关代码</span></span><br><span class="line"></span><br><span class="line">TIM_HandleTypeDef htim2;</span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">void</span> <span class="title">MX_TIM2_Init</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM2_Init 0 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM2_Init 0 */</span></span><br><span class="line"></span><br><span class="line">  TIM_ClockConfigTypeDef sClockSourceConfig = &#123;<span class="number">0</span>&#125;;</span><br><span class="line">  TIM_MasterConfigTypeDef sMasterConfig = &#123;<span class="number">0</span>&#125;;</span><br><span class="line"></span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM2_Init 1 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM2_Init 1 */</span></span><br><span class="line">  htim2.Instance = TIM2;</span><br><span class="line">  htim2.Init.Prescaler = <span class="number">8399</span>;</span><br><span class="line">  htim2.Init.CounterMode = TIM_COUNTERMODE_UP;</span><br><span class="line">  htim2.Init.Period = <span class="number">4999</span>;</span><br><span class="line">  htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;</span><br><span class="line">  htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIM_Base_Init(&amp;htim2) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIM_ConfigClockSource(&amp;htim2, &amp;sClockSourceConfig) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;</span><br><span class="line">  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;</span><br><span class="line">  <span class="keyword">if</span> (HAL_TIMEx_MasterConfigSynchronization(&amp;htim2, &amp;sMasterConfig) != HAL_OK)</span><br><span class="line">  &#123;</span><br><span class="line">    Error_Handler();</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM2_Init 2 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM2_Init 2 */</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//此函数会被HAL_TIM_Base_Init()函数调用</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">HAL_TIM_Base_MspInit</span><span class="params">(TIM_HandleTypeDef* htim_base)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">if</span>(htim_base-&gt;Instance==TIM2)</span><br><span class="line">  &#123;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM2_MspInit 0 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM2_MspInit 0 */</span></span><br><span class="line">    <span class="comment">/* Peripheral clock enable */</span></span><br><span class="line">    __HAL_RCC_TIM2_CLK_ENABLE();</span><br><span class="line">    <span class="comment">/* TIM2 interrupt Init */</span></span><br><span class="line">    HAL_NVIC_SetPriority(TIM2_IRQn, <span class="number">0</span>, <span class="number">0</span>);</span><br><span class="line">    HAL_NVIC_EnableIRQ(TIM2_IRQn);</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM2_MspInit 1 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM2_MspInit 1 */</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//中断函数</span></span><br><span class="line"><span class="keyword">extern</span> TIM_HandleTypeDef htim2;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">TIM2_IRQHandler</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM2_IRQn 0 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM2_IRQn 0 */</span></span><br><span class="line">  HAL_TIM_IRQHandler(&amp;htim2);</span><br><span class="line">  <span class="comment">/* USER CODE BEGIN TIM2_IRQn 1 */</span></span><br><span class="line">  <span class="comment">/* USER CODE END TIM2_IRQn 1 */</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//中断会触发一个callback函数，一般在callback函数中进行所要执行的操作，如下图所示我们找到callback函数，可以看到他是一个__weak函数，也就是我们可以在其他文件中重新定义他。</span></span><br></pre></td></tr></table></figure>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202310141007680.png"></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">HAL_TIM_PeriodElapsedCallback</span><span class="params">(TIM_HandleTypeDef *htim)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">if</span>(htim-&gt;Instance == TIM2)</span><br><span class="line">	&#123;</span><br><span class="line">			LED0_Toggle();</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/10/12/%E6%9D%B0%E7%90%86%E4%B8%B2%E5%8F%A3%E6%94%AF%E6%8C%81%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C%E4%B9%8B%E5%8F%91%E9%80%81/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/10/12/%E6%9D%B0%E7%90%86%E4%B8%B2%E5%8F%A3%E6%94%AF%E6%8C%81%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C%E4%B9%8B%E5%8F%91%E9%80%81/" class="post-title-link" itemprop="url">杰理串口支持奇偶校验之发送</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-10-12 18:55:02" itemprop="dateCreated datePublished" datetime="2023-10-12T18:55:02+08:00">2023-10-12</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/10/12/%E6%9D%B0%E7%90%86%E4%B8%B2%E5%8F%A3%E6%94%AF%E6%8C%81%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C%E4%B9%8B%E5%8F%91%E9%80%81/" class="post-meta-item leancloud_visitors" data-flag-title="杰理串口支持奇偶校验之发送" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/10/12/%E6%9D%B0%E7%90%86%E4%B8%B2%E5%8F%A3%E6%94%AF%E6%8C%81%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C%E4%B9%8B%E5%8F%91%E9%80%81/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/10/12/%E6%9D%B0%E7%90%86%E4%B8%B2%E5%8F%A3%E6%94%AF%E6%8C%81%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C%E4%B9%8B%E5%8F%91%E9%80%81/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="奇偶校验概念"><a href="#奇偶校验概念" class="headerlink" title="奇偶校验概念"></a>奇偶校验概念</h3><p>​        奇偶检验需要使用到一位校验位。</p>
<p>奇校验（odd parity）：让传输的数据（包含校验位）中1的个数为奇数。</p>
<p>即：如果传输字节中1的个数是偶数，则校验位为“1”，奇数相反。</p>
<p>以发送字符：10101010为例</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230509154845.png" style="zoom:50%;">

<p>偶校验（even parity）：让传输的数据（包含校验位）中1的个数为偶数。</p>
<p>即：如果传输字节中1的个数是偶数，则校验位为“0”，奇数相反。</p>
<p>还是以发送字符：10101010为例</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230509154936.png" style="zoom:50%;">

<h3 id="杰理AC6956C增加串口发送奇偶校验功能"><a href="#杰理AC6956C增加串口发送奇偶校验功能" class="headerlink" title="杰理AC6956C增加串口发送奇偶校验功能"></a>杰理AC6956C增加串口发送奇偶校验功能</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20230509155236.png" style="zoom:77%;">

<p>​        用单字节模式，原来的uart_tx_buf，uart_async_tx_buf这些函数不能使用，他们都是dma发送的。<strong>校验位模式，只能存在于单字节模式，数据量会比较低，波特率不能高，不能使用DMA模式</strong>，需要使用uart_tx_byte函数。    </p>
<p>​        修改发送代码，在需要奇偶校验的时候，使能9bit模式，发送结束就失能，如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">uart_eventx_byte</span><span class="params">(<span class="keyword">int</span> id, u8 byte)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    JL_UART_TypeDef *reg = uart_hdl[id].reg;</span><br><span class="line">    reg-&gt;CON0 |= BIT(<span class="number">1</span>);       <span class="comment">//使能校验位</span></span><br><span class="line"></span><br><span class="line">    u8 prd = byte;</span><br><span class="line">    u8 cnt = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span>(u8 i=<span class="number">0</span>; i&lt;<span class="number">8</span>; i++)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">if</span>(prd &amp; BIT(<span class="number">7</span>))</span><br><span class="line">        &#123;</span><br><span class="line">            cnt++;</span><br><span class="line">        &#125;</span><br><span class="line">        prd = prd &lt;&lt; <span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span>(cnt % <span class="number">2</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        reg-&gt;CON0 |= BIT(<span class="number">9</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        reg-&gt;CON0 &amp;= ~BIT(<span class="number">9</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    uart_tx_byte(id, byte); <span class="comment">//发送byte,调用的官方sdk库里面的函数</span></span><br><span class="line"></span><br><span class="line">    reg-&gt;CON0 &amp;= ~BIT(<span class="number">1</span>);   <span class="comment">//失能校验位</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​        带偶校验分别发送了【0x55】和【0x57, 0xAA】,用示波器抓取了相应波形，所测串口的电平为TTL 电平，该电平的串口在不传输数据时电平为高，靠拉低判断起始位。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230509202617.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20230509202658.jpg" style="zoom:30%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20230509202743.jpg" style="zoom:30%;">

<p>​        上面的都是带有偶校验的，下面两个图是发送【0x55】和【0x57, 0xAA】不带校验相应的波形，做个比较：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20230509203041.jpg" style="zoom:30%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20230509203116.jpg" style="zoom:30%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/09/17/ADC%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B9%8B%E6%B7%B7%E5%8F%A0%E6%95%88%E5%BA%94/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/09/17/ADC%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B9%8B%E6%B7%B7%E5%8F%A0%E6%95%88%E5%BA%94/" class="post-title-link" itemprop="url">ADC常见问题之混叠效应</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-09-17 20:05:09" itemprop="dateCreated datePublished" datetime="2023-09-17T20:05:09+08:00">2023-09-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2023/09/17/ADC%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B9%8B%E6%B7%B7%E5%8F%A0%E6%95%88%E5%BA%94/" class="post-meta-item leancloud_visitors" data-flag-title="ADC常见问题之混叠效应" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/09/17/ADC%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B9%8B%E6%B7%B7%E5%8F%A0%E6%95%88%E5%BA%94/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/09/17/ADC%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B9%8B%E6%B7%B7%E5%8F%A0%E6%95%88%E5%BA%94/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文链接：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Sq4y1u7sZ/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1Sq4y1u7sZ/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        下图蓝色的是我们实际的信号，当我们AD的采样频率高于这个信号的9倍，黄色的就是AD取样的波形，基本已经还原了实际波形。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917200849.png" style="zoom:80%;">

<p>​        当我们的取样频率开始下降，当取样频率达到奈奎斯特采样频率的时候：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917201350.png" style="zoom:67%;">

<p>存在的问题是实际上蓝色线并不存在上面的这个包络线，但因为采样频率的关系，除了造成原本频率部分有所失真，更大的问题在于产生了一个原本不存在的频率。</p>
<p>​        当采样频率只有实际的一半时：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917201738.png" style="zoom:67%;">

<p>这时候可以看到包络线有变多严重：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917202211.png" style="zoom:80%;">

<h3 id="看下面的混叠例子："><a href="#看下面的混叠例子：" class="headerlink" title="看下面的混叠例子："></a>看下面的混叠例子：</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917202527.png" style="zoom:80%;">

<p>​        假设我的AD采样频率是100Hz， 所以我的奈奎斯特频率就是50Hz。混叠效应告诉我们，一旦高于奈奎斯特的频率都可以折叠出低于奈奎斯特的频率，高频部分是真的，低频部分是假的。</p>
<p>​        遇到这个问题该怎么办？应该要和硬件工程师讨论，我的AD速度是多少，我奈奎斯特频率是多少，所以所有信号进mcu的ADC pin之前，要有一个低通滤波器，把高于奈奎斯特的频率尽可能过滤掉。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/09/17/free%E9%87%8A%E6%94%BE%E5%86%85%E5%AD%98%E7%9A%84%E6%97%B6%E5%80%99%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E9%9C%80%E8%A6%81%E6%8C%87%E5%AE%9A%E5%86%85%E5%AD%98%E5%A4%A7%E5%B0%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/09/17/free%E9%87%8A%E6%94%BE%E5%86%85%E5%AD%98%E7%9A%84%E6%97%B6%E5%80%99%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E9%9C%80%E8%A6%81%E6%8C%87%E5%AE%9A%E5%86%85%E5%AD%98%E5%A4%A7%E5%B0%8F/" class="post-title-link" itemprop="url">free释放内存的时候为什么不需要指定内存大小</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-09-17 17:49:59" itemprop="dateCreated datePublished" datetime="2023-09-17T17:49:59+08:00">2023-09-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/09/17/free%E9%87%8A%E6%94%BE%E5%86%85%E5%AD%98%E7%9A%84%E6%97%B6%E5%80%99%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E9%9C%80%E8%A6%81%E6%8C%87%E5%AE%9A%E5%86%85%E5%AD%98%E5%A4%A7%E5%B0%8F/" class="post-meta-item leancloud_visitors" data-flag-title="free释放内存的时候为什么不需要指定内存大小" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/09/17/free%E9%87%8A%E6%94%BE%E5%86%85%E5%AD%98%E7%9A%84%E6%97%B6%E5%80%99%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E9%9C%80%E8%A6%81%E6%8C%87%E5%AE%9A%E5%86%85%E5%AD%98%E5%A4%A7%E5%B0%8F/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/09/17/free%E9%87%8A%E6%94%BE%E5%86%85%E5%AD%98%E7%9A%84%E6%97%B6%E5%80%99%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E9%9C%80%E8%A6%81%E6%8C%87%E5%AE%9A%E5%86%85%E5%AD%98%E5%A4%A7%E5%B0%8F/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文链接：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Hw411i7aF/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1Hw411i7aF/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        free释放内存，为什么不需要指定内存大小？</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917175052.png" style="zoom:60%;">

<p>​        原因是malloc在申请内存的时候，申请到的内存往往比我们需要的内存要稍微大一点，也就是在我们能使用的内存前面会多出一块内存，存放头部信息，这个信息就包含了接下来这块内存的大小。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917175344.png" style="zoom:67%;">

<p>​        UNIX环境高级编程一书中有提到过：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917175538.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/09/17/CAN%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E5%8F%8A%E5%85%B6HAL%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/09/17/CAN%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E5%8F%8A%E5%85%B6HAL%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F/" class="post-title-link" itemprop="url">CAN工作原理及其HAL驱动程序</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-09-17 17:25:34" itemprop="dateCreated datePublished" datetime="2023-09-17T17:25:34+08:00">2023-09-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/09/17/CAN%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E5%8F%8A%E5%85%B6HAL%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F/" class="post-meta-item leancloud_visitors" data-flag-title="CAN工作原理及其HAL驱动程序" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/09/17/CAN%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E5%8F%8A%E5%85%B6HAL%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/09/17/CAN%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E5%8F%8A%E5%85%B6HAL%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1P14y1z7WC/?spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1P14y1z7WC/?spm_id_from=pageDriver&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        <a target="_blank" rel="noopener" href="https://blog.csdn.net/m0_69251699/article/details/131583713">https://blog.csdn.net/m0_69251699/article/details/131583713</a></p>
<h3 id="片上CAN外设的功能概述"><a href="#片上CAN外设的功能概述" class="headerlink" title="片上CAN外设的功能概述"></a>片上CAN外设的功能概述</h3><p>​        stm32f4器件上有两个基本扩展can外设，我们称之为can模块，如下图所示。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202309092216205.png" style="zoom:80%;">

<p>​        其中can1是带有512字节sram的主can控制器，can2无法直接访问sram存储器，是从can控制器。</p>
<p>​        每个can模块都有3个发送邮箱，每个can模块有两个FIFO接收单元，每个FIFO有3个接收邮箱。每个FIFO有独立的中断地址。</p>
<p>​        2个can模块共用28个筛选器组，<strong>筛选器组用于配置可接收ID列表或掩码，数据帧和遥控帧根据ID被筛选。只有通过筛选的帧才能进入接收邮箱</strong>。帧的筛选完全由硬件来完成，减少处理器的负担。</p>
<p>​        上面讲的只是can控制器，如果要构成一个can节点，mcu还需要外接一个can收发器芯片，实现mcu逻辑电平到can总线物理层的电平转换和控制。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202309092231253.png" style="zoom:80%;">

<p>​        上图是闭环结构，开发板上的CAN通信接口电路使用SIT1050T芯片。</p>
<p>​        下面搞一个demo，我们使用开发板上的can通信电路，测试轮询模式的can通信编程。<strong>使用can测试模式中的回环功能进行自发自收的测试</strong>，<strong>设置筛选器组只接收ID为奇数的消息，使用轮询方式来接收数据</strong>。</p>
<h3 id="Cubemx配置"><a href="#Cubemx配置" class="headerlink" title="Cubemx配置"></a>Cubemx配置</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202309101027981.png" style="zoom:67%;">

<p>​        直接将can1启用，点击生成代码，看下stm32f4xx_hal_can.h文件有哪些函数。首先can模块的基本控制，can模块有3种主要的工作模式：初始化，正常和睡眠。硬件复位后，can模块处于睡眠模式；在初始化模式下，可以对can模块进行初始化设置；在正常模式下，可以进行数据的接收和发送。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202309101042748.png"></p>
<p>比如HAL_CAN_RequeseSleep函数使can模块在完成当前操作后进入睡眠模式。</p>
<h3 id="CAN模块的测试模式"><a href="#CAN模块的测试模式" class="headerlink" title="CAN模块的测试模式"></a>CAN模块的测试模式</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202309101058117.png" style="zoom:70%;">

<p>​        在静默模式下，can模块可以接收有效的数据帧和遥控帧，但只能发出隐性位,而不能真正发送报文。所以在静默模式下，can模块无法启动发送操作。这种模式一般用于监测总线流量。</p>
<p>​        回环模式下，can模块可以正常向总线发送数据，但不能接收总线的数据，只能接收自己发送的数据，这种模式可以用于自检测试。为了不受外部事件的影响，can内核在此模式下，不会对数据帧或遥控帧的ACK段采样，这样就可以忽略ACK错误。</p>
<p>​        回环和静默组合模式，可以用于热自检，这种模式下，can模块不能接收总线上的数据，只能接收自己发送的数据，只能向总线上发送隐性位，因而不会影响can总线。</p>
<h3 id="CAN模块发送消息相关的函数"><a href="#CAN模块发送消息相关的函数" class="headerlink" title="CAN模块发送消息相关的函数"></a>CAN模块发送消息相关的函数</h3><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202309112259838.png"></p>
<h3 id="CAN模块消息接收相关的函数"><a href="#CAN模块消息接收相关的函数" class="headerlink" title="CAN模块消息接收相关的函数"></a>CAN模块消息接收相关的函数</h3><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202309112308280.png"></p>
<h3 id="标识符筛选原理"><a href="#标识符筛选原理" class="headerlink" title="标识符筛选原理"></a>标识符筛选原理</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/8c2d743ba36646199cf2d1ce3f4e4f90.png" style="zoom:80%;">

<p>​        发送节点是以广播的形式发送的，所有的can节点都能收到消息。数据帧和遥控帧带有标识符，标识符一般表示消息的类型。一个can节点一般只对特定的消息感兴趣，如果用软件对接收的帧ID进行判别，将消耗接收节点的大量cpu时间。</p>
<p>​        筛选器的工作主要是筛选ID的长度和筛选模式决定的。</p>
<p>​        筛选ID的长度有两种，分别是16位和31位，如下：</p>
<p>​        (1) 检查 STDID[10:0]、 EXTID[17:0]、 IDE 和 RTR 位， 一共31位。</p>
<p>​        (2) 检查STDID[10:0]、 RTR、 IDE 和 EXTID[17:15]， 一共16位。</p>
<p>​        筛选模式分两种，分别是标识列表模式和掩码模式，如下：</p>
<p>​        (1) 标识符列表模式，它把要接收报文的ID列成一个表， 要求报文ID与列表中的某一个标识符完全相同才可以接收，可以理解为白名单管理。</p>
<p>​        (2) 掩码模式，它把可接收报文ID的某几位作为列表，这几位被称为掩码， 可以把它理解成关键字搜索，只要掩码(关键字)相同，就符合要求，报文就会被保存到接收FIFO。</p>
<p>​        两种筛选模式用通俗的话来讲，标识列表模式就是把所有的ID放在一个表里，一个一个的去查，查到与标识的ID相同的报文选择接收，其他的报文不接受；掩码模式就是，对应ID的每一个位，都有一个掩码的位去决定，如下表：<br><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917165824.png" style="zoom:80%;"></p>
<p>当掩码是1时，就表明要接收的报文ID就必须和存储的ID一致，当掩码是0是，就是不关心要筛选的ID这一位可以是0，也可以是1。</p>
<h3 id="中断及其处理"><a href="#中断及其处理" class="headerlink" title="中断及其处理"></a>中断及其处理</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230917172119.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/6/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/6/">6</a><span class="page-number current">7</span><a class="page-number" href="/page/8/">8</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/8/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
